﻿Imports BUS
Imports DTO
Public Class frmthemnhanvien

    Private Sub frmthemnhanvien_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim dsbc As New List(Of BangCapDTO)()
        Dim busbc As New BangCapBUS()
        dsbc = busbc.LayDSBangCap()
        LookUpbangcap.Properties.DataSource = dsbc
        LookUpbangcap.Properties.DisplayMember = "TenBangCap"
        LookUpbangcap.Properties.ValueMember = "MaBangCap"

        Dim dsbp As New List(Of BoPhanDTO)()
        Dim busbp As New BoPhanBUS()
        dsbp = busbp.LayDSBoPhan()
        LookUpbophan.Properties.DataSource = dsbp
        LookUpbophan.Properties.DisplayMember = "TenBoPhan"
        LookUpbophan.Properties.ValueMember = "MaBoPhan"
        Dim dscv As New List(Of ChucVuDTO)()
        Dim buscv As New ChucVuBUS()
        dscv = buscv.LayDSChucVu()
        LookUpchucvu.Properties.DataSource = dscv
        LookUpchucvu.Properties.DisplayMember = "TenChucVu"
        LookUpchucvu.Properties.ValueMember = "MaChucVu"
        LookUpbangcap.EditValue = 4
        LookUpbophan.EditValue = 1
        LookUpchucvu.EditValue = 5
    End Sub

    Private Sub btnthem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnthem.Click
        If DateEditngaysinh.DateTime.Year >= DateTime.Now.Year - 18 Then
            MessageBox.Show("Nhan vien phai tren 18 tuoi !")
            Return
        End If
        Dim sql As String = "Insert INTO NHANVIEN(HoTen,NgaySinh,DiaChi,DienThoai,MaBangCap,MaBoPhan,MaChucVu) "
        sql = sql + "Values(" + "'" + txthoten.Text + "'" + "," + "'" + DateEditngaysinh.DateTime + "'" + "," + "'" + txtdiachi.Text + "'" + ","
        sql = sql + "'" + mtxtdienthoai.Text + "'" + "," + LookUpbangcap.EditValue.ToString() + "," + LookUpbophan.EditValue.ToString() + "," + LookUpchucvu.EditValue.ToString() + ")"
        Dim bus As New NhanVienBUS()
        Dim kq As Integer = bus.ThemNhanVien(sql)
        If kq = 1 Then
            MessageBox.Show("Thêm thành công !")
        Else
            MessageBox.Show("Thêm thất bại !")
        End If
    End Sub

End Class